<?php use_helper('I18N', 'Date') ?>
<li id="feed_<?php echo $bulletin_board->getId() ?>" class="feed">
    <div style="display: none" id="removed_post_<?php echo $bulletin_board->getId() ?>" class="removed_post">
        You're no longer seeing this post <a class="undo_remove_post" hre="#">Undo remove</a>
    </div>
    <div id="post_<?php echo $bulletin_board->getId() ?>">
        <div class="content-row">
            <div class="poster-image">
                <img src="/uploads/users/6/avatar_48.png" alt="Fox Matuku"/>
            </div>
            <div class="post-owner">
                <a href="/backend.php/profile"><?php echo $bulletin_board->getUser() ?></a> - <span class="datetime"><?php echo false !== strtotime($bulletin_board->getUpdatedAt()) ? distance_of_time_in_words(strtotime($bulletin_board->getUpdatedAt())) . " ago" : '&nbsp;' ?></span>
            </div>
            <div class="post-body">
                <?php echo $bulletin_board->getPost() ?>
                <div class="post-action">
                    <a class="like-post" href="#">Like</a><span class="dot-separater">.</span><a class="comment-post" href="#">Comment</a>	      					
                </div>
                <div class="remove_post">&nbsp;</div>
            </div>            
        </div>
        <div class="content-row">
            <div class="post-comments"> 
                <?php $comments_count = $bulletin_board->getBulletinBoardComment()->count() ?>
                <?php if ($comments_count >= 1): ?>
                    <div style="display: block" class="show_hide_post_comments" id="show_hide_post_comments_<?php echo $bulletin_board->getId() ?>">
                        <div class="no_of_comments">
                            <a href="#"><?php echo $comments_count ?> comment<?php echo $comments_count > 1 ? "s" : "" ?></a>
                            <span class="expand">&nbsp;</span>
                        </div>
                    </div>
                    <div id="comments_<?php echo $bulletin_board->getId() ?>" class="comments hide">
                        <?php foreach ($bulletin_board->getBulletinBoardComment() as $bulletin_board_comment): ?>            
                            <?php include_partial('bulletin_board_comment/comment_div', array("bulletin_board_comment" => $bulletin_board_comment)) ?>
                        <?php endforeach; ?>
                    </div>
                <?php endif; ?>
                <div class="comment-prompt">
                    <textarea name="bulletin_board[post_<?php echo $bulletin_board->getId() ?>]" title="Add a comment..." id="bulletin_board_post_<?php echo $bulletin_board->getId() ?>" class="prompt bulletin_comment">Add a comment...</textarea>
                    <ul id="comment_action_<?php echo $bulletin_board->getId() ?>" class="sf_admin_actions sf_admin_comment_actions" style="clear:both">
                        <li class="sf_admin_action_new">
                            <input id="post_form_<?php echo $bulletin_board->getId() ?>" class="save" type="button" value="+ Post comment">
                        </li>
                    </ul>
                </div>            
            </div>
        </div>
    </div>
</li>
<script type="text/javascript">
    $(document).ready(function(){
        $('#bulletin_board_post_<?php echo $bulletin_board->getId() ?>').focus(function(){	
            $("#comment_action_<?php echo $bulletin_board->getId() ?>").show();
        }).blur(function(){	
            if($(this).val() == "Add a comment..." || $(this).val() == ""){
                $("#comment_action_<?php echo $bulletin_board->getId() ?>").hide();
            }
        });
        
        $('#post_form_<?php echo $bulletin_board->getId() ?>').click(function(){
            $('#bulletin_board_comment_bulletin_board_id').val(<?php echo $bulletin_board->getId() ?>);
            $('#bulletin_board_comment_content').val($('#bulletin_board_post_<?php echo $bulletin_board->getId() ?>').val());
           
            if($("#bulletin_board_comment_content").val() != "Add a comment..." && $("#bulletin_board_comment_content").val() != ""){
                $("#bulletin_board_comment_form").ajaxSubmit(function(data){
                    $('#bulletin_board_post_<?php echo $bulletin_board->getId() ?>').val("Add a comment...");
                    $("#comments_<?php echo $bulletin_board->getId() ?>").append(data);
                });                
            }
        });
    });
</script>